package com.forlove.app.qselect.index.adapter;

import android.content.Context;
import android.widget.TextView;

import com.forlove.app.R;
import com.forlove.app.common.base.mvp.presenter.IBasePresenter;
import com.forlove.app.common.widget.CircleImageView;
import com.forlove.app.common.widget.recyview.BaseRecyclerAdapter;
import com.forlove.app.common.widget.recyview.ViewHolder;
import com.forlove.app.qselect.friend.entity.MineFriendEntity;

import java.util.List;

/**
 * Created by yinzhiqiang on 2017/11/6.
 */

public class AddFriendsAdapter extends BaseRecyclerAdapter<MineFriendEntity> {
    public AddFriendsAdapter(Context context, int itemView, List<MineFriendEntity> mDatas, IBasePresenter presenter) {
        super(context, itemView, mDatas, presenter);
    }

    @Override
    protected void convertView(ViewHolder holder, MineFriendEntity entity, int position) {
        CircleImageView photo = holder.getView(R.id.cv_image_portrait);
        if (basePresenter != null) {
            basePresenter.loadImageView(mContext, photo, entity.img, R.mipmap.image_mine_friend_avatar);
        }
        TextView userName = holder.getView(R.id.tv_friend_name);
        userName.setText(entity.getAvaliableName());

        //TODO 具体展示问题
        if (entity.isFromContacts) {
            holder.setText(R.id.tv_from, "通讯录好友");
        } else {
            holder.setText(R.id.tv_from, "圈一圈好友");
        }
        if (entity.isRecomend) {
            holder.setVisible(R.id.iv_checkout, true);
            holder.getConvertView().setBackgroundResource(R.drawable.bg_add_friends_click);
        } else {
            holder.setVisible(R.id.iv_checkout, false);
            holder.getConvertView().setBackgroundResource(R.drawable.bg_add_friends_gray);
        }
    }
}
